/*
//confirm la alshbak
if (confirm("Are you sure you want to do that?")) {
alert("You said yes");
}
else {
alert("You said no");
}
var ans = prompt("Are you sure you want to do that ? ","");
if (ans) {
alert ("you said" + ans );
}
else {
alert ("you refused to answer");
}
*/
/*
//men shan al number 3la alshashe 7sab lesson 4
var x=parseInt(prompt("plaease enter the first number"));
var y=parseInt(prompt("plaease enter the first number"));
var z=x+y;
alert("the result of adding "+x +" and " +y+" the addition is : " +z);
*/
//var x=parseInt(prompt("plaease enter the first number"));
//var y=parseInt(prompt("plaease enter the first number"));
/*
function addition (x,y)
{
z=x+y;
return z;
}
var z=addition (x,y);
document.write ("the result of adding "+x +" and " +y+" the addition is : " +z);
*/
var x=parseInt(prompt("please enter the first number"));
var y=parseInt(prompt("please enter the second number"));
var z=prompt("please type add for addition,sub for subtraction,mul for multiplication ,div for division");
if (z=="add")
addition(x,y);
else if (z=="sub")
subtraction(x,y);
else if (z=="mul")
multiplication(x,y);
else if (z=="div")
division(x,y);
function subtraction (x,y)
{
z=x-y;
document.write ("the result of adding "+x +" and " +y+" the subtraction is : " +z);
if (y==0)
alert (
}
function addition (x,y)
{
z=x+y;
document.write ("the result of adding "+x +" and " +y+" the addition is : " +z);
}
function multiplication (x,y)
{
z=x*y;
document.write ("the result of adding "+x +" and " +y+" the multipliction is : " +z);
}
function division (x,y)
{
z=x/y;
document.write ("the result of adding "+x +" and " +y+" the division is : " +z);
}
---------------------------
var a=parseInt(prompt("Please enter a number"));
var b=parseInt(prompt("Please enter another number"));
var z=prompt("For division type div");
if (z=="div") division (a,b);
else{ alert("you refused to answer"); }
function division(a,b)
{if(b==0) { alert("You can't divide with 0"); } else{ var z=a/b; document.write("the result of the division "+a+" and "+b+" is: " +z);} }

Post a Comment